var TableManaged = function () {

    return {

        //main function to initiate the module
        init: function (provinceid,city) {
            if (!jQuery().dataTable) {
                return;
            }
            var ajaxsource="";
            if(city==null||city==undefined||city==""){
                ajaxsource="http://localhost:9999/order/getHospitalAllByCityId?cityId=4401&provinceid=44";
            }else{
                ajaxsource="http://localhost:9999/order/getHospitalAllByCityId?cityId="+city+"&provinceid="+provinceid;
            }
            $('#hospitalListTable').dataTable({

                "bProcessing": true,
                "sAjaxSource": ajaxsource,
                "sAjaxDataProp": "data",
                "aoColumns": [
                    { "mData": "id" },
                    { "mData": "hospitalName" },
                    { "mData": null,
                      "mRender": function ( data, type, full ) {
                          console.info('full---->');
                          console.info(full);
                          var featureProject=full.featureProject;
                          var projectarr=new Array();
                          if(featureProject!=null&&featureProject!=undefined){
                              for(var i in featureProject){
                                  projectarr.push(featureProject[i].projectName);
                              }
                          }
                          return projectarr.join(",")+"<input type='hidden' id='hp_"+full.id+"' value='"+projectarr.join(",")+"'>"+"</input>";
                        }
                    }
                ],
                "aLengthMenu": [
                    [5, 15, 20, -1],
                    [5, 15, 20, "All"] // change per page values here
                ],
                // set the initial value
                "iDisplayLength": 5,
                "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
                "sPaginationType": "bootstrap",
                "oLanguage": {
                    "sLengthMenu": "_MENU_ 条",
                    "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
                    "oPaginate": {
                        "sPrevious": "",
                        "sNext": ""
                    }
                },
                "aoColumnDefs": [{
                        'bSortable': false,
                        'aTargets': [0]
                    }
                ],
                "bDestroy": true
            });

            jQuery('#hospitalListTable_wrapper .dataTables_filter input').addClass("m-wrap small"); // modify table search input
            jQuery('#hospitalListTable_wrapper .dataTables_length select').addClass("m-wrap small"); // modify table per page dropdown
            jQuery('#hospitalListTable_wrapper .dataTables_length select').select2(); // initialzie select2 dropdown

            jQuery("#hospitalListTable").removeAttr("style");

        }

    };

}();